<template>
	<view class="column h100">
		<view class="plr30 pt31 pb14 justify-start">
			<view class="center bgf radius20 flex-1 active_bg" style="height: 150rpx" @click="navTo('pages/message/clue')">
				<u-image src="https://monvkeji.oss-cn-chengdu.aliyuncs.com/xunche/message/line-manage.png" width="76rpx"
					height="76rpx" />
				<text class="ml30 fs30">线索管理</text>
			</view>
			<view class="center ml29 bgf radius20 flex-1 active_bg" style="height: 150rpx"
				@click="navTo('pages/message/system')">
				<u-image src="https://monvkeji.oss-cn-chengdu.aliyuncs.com/xunche/message/system-manage.png" width="76rpx"
					height="76rpx" />
				<text class="ml30 fs30">系统消息</text>
			</view>
		</view>
		<view class="bgf radius20 mlr30 p30 center mt20" @click="openConversationList">
			<u-icon name="chat-fill" size="76rpx" color="#41b6fc" />
			<text class="ml20">私聊信息</text>
		</view>
		<!-- <scroll-view scroll-y class="flex-1 hidden" :refresher-enabled="scrollViewTool.isEnabled"
			refresher-background="rgba(0,0,0,0)" :refresher-triggered="scrollViewTool.triggered"
			@refresherrefresh="pullDownRefresh" @refresherrestore="scrollViewTool.triggered = false"
			@refresherabort="triggered = false" @scrolltolower="reachBottom">
			<template v-for="(item, index) in messageList" :key="index">
				<view class="message-item active_bg" @click="openConversationList(item)">
					<u-image src="https://monvkeji.oss-cn-chengdu.aliyuncs.com/xunche/message/system-manage.png" radius="43rpx"
						width="85rpx" height="85rpx"></u-image>
					<view class="right">
						<view class="justify-between align-center">
							<text class="title">{{item.To_Account}}</text>
							<text class="time">{{$u.timeFormat(item.MsgTime, 'yyyy-mm-dd hh:MM:ss')}}</text>
						</view>
						<view class="justify-between align-center mt7">
							<view class="u-line-1 flex-1">在的</view>
							<view class="ml30">
								<u-badge bgColor="#FF7171" color="#FFFFFF" :max="99" :value="1" />
							</view>
						</view>
					</view>
				</view>
				<u-line v-if="index<2" color="#D3D3D3"></u-line>
			</template>
		</scroll-view> -->
	</view>
</template>

<script setup>
	import {
		TUIChatKit
	} from '@/TUIKit';
	TUIChatKit.init();
	import {
		TUILogin
	} from '@tencentcloud/tui-core';
	import {
		getUserSig,
	} from '@/api/message/index.js';
	import {
		ref,
		nextTick
	} from 'vue';
	import {
		navTo
	} from '@/core/app';
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	import {
		getSessionList
	} from "@/api/message/index";
	import {
		useLoadPageList
	} from '@/hooks/useLoadPageList/useLoadPageList';

	const {
		listData,
		loadStatus,
		scrollViewTool,
		reachBottom,
		pullDownRefresh,
		reSetList
	} = useLoadPageList();
	// 获取消息列表
	onShow(() => {
		// getMessageList()
		if (!uni.$SDKAppID) {
			nextTick(() => {
				getUserSig().then(res => {
					uni.showLoading()
					uni.$SDKAppID = 1600090702; // Your SDKAppID
					uni.$userID = res.data.im_user_id; // Your userID
					uni.$userSig = res.data.im_user_sig; // Your userSig
					TUILogin.login({
						SDKAppID: uni.$SDKAppID,
						userID: uni.$userID,
						userSig: uni.$userSig,
						useUploadPlugin: true, // If you need to send rich media messages, please set to true.
						framework: `vue3` // framework used vue2 / vue3
					}).catch(() => {});
					setTimeout(() => {
						uni.hideLoading()
					}, 1000)
				})
			})

		}
	})
	onLoad(() => {

	})
	const openConversationList = () => {
		uni.navigateTo({
			url: `/TUIKit/components/TUIConversation/index`
		});
	}
</script>

<style scoped lang="scss">
	.message-item {
		display: flex;
		padding: 38rpx 31rpx 30rpx 41rpx;
		box-sizing: border-box;
		background-color: #ffffff;

		.right {
			margin-left: 15rpx;
			flex: 1;

			.title {
				font-weight: bold;
				font-size: 28rpx;
				color: #000000;
			}

			.time {
				font-weight: 400;
				font-size: 24rpx;
				color: #999999;
			}
		}
	}
</style>